package com.longcai.piaojia.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/9/21.
 */
@HttpInlet(Conn.ORDER_INDEX_TIME)
public class ChooseGoodsListGet extends BaseAsyGet<ChooseGoodsListGet.ChooseGoodsListEntity> {

    public String id, group_id;

    public ChooseGoodsListGet(AsyCallBack<ChooseGoodsListEntity> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected ChooseGoodsListEntity parser(JSONObject object) throws Exception {

        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            ChooseGoodsListEntity chooseGoodsListEntity = new ChooseGoodsListEntity();

            chooseGoodsListEntity.discount = object.optString("discount");

            JSONArray array = object.optJSONArray("data");

            for (int i = 0; i < array.length(); i++) {

                JSONObject objectTime = array.optJSONObject(i);

                TimeEntity timeEntity = new TimeEntity();

                timeEntity.id = objectTime.optString("id");
                timeEntity.data = objectTime.optString("data");
                timeEntity.hour = objectTime.optString("hour");
                timeEntity.week = objectTime.optString("week");
                timeEntity.performance_time = objectTime.optString("performance_time");
                timeEntity.is_balance = objectTime.optString("is_balance");

                chooseGoodsListEntity.TimeEntityList.add(timeEntity);

            }

            return chooseGoodsListEntity;

        }

        return null;
    }

    public static class ChooseGoodsListEntity {

        public String discount;

        public List<TimeEntity> TimeEntityList = new ArrayList<>();

    }

    public static class TimeEntity {

        public String id, data, hour, week, performance_time, is_balance;

    }


}
